package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {

    /**
     * 根据openid查询用户
     * @param openid
     * @return
     */
    @Select("select * from user where openid = #{openid}")
    User getByOpenid(String openid);

    /**
     * 插入数据
     * 数据插入之后，需要把用户的主键值id返回，因为在UserController层login方法会用到getId,即在配置文件中的useGeneratedKeys="true" keyProperty="id"来获取主键值id
     * @param user
     */
    void insert(User user);

    /**
     *根据id查询当前登录微信用户信息
     * @param userId
     * @return
     */
    @Select("select * from user where id = #{id}")
    User getById(Long userId);


}
